﻿using System;

namespace Cms.Domain
{
    public class Membership
    {
        private DateTime? _endDate;
        private DateTime? _startDate;
        
        public virtual int ID { get; set; }
        
        public virtual User User { get; set; }
        
        public virtual UserGroup UserGroup { get; set; }

        public virtual Subscription Subscription { get; set; }

        public virtual OrderLine OrderLine { get; set; }

        public virtual DateTime? StartDate
        {
            get { return _startDate; }
            set { _startDate = value; }
        }

        public virtual DateTime? EndDate
        {
            get { return _endDate; }
            set { _endDate = value; }
        }

        public virtual bool IsActive()
        {
            bool active = true;
            if (_startDate.HasValue && _startDate > DateTime.Now)
                active = false;
            if (_endDate.HasValue && _endDate < DateTime.Now)
                active = false;
            return active;
        }
    }
}